package com.admin.config.db;
import java.sql.SQLException;

import javax.sql.DataSource;

import com.admin.config.db.properties.DruidProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;

@Configuration
public class DBconfig {

    @Bean
    @ConfigurationProperties("spring.datasource.druid")
    public DataSource masterDataSource(DruidProperties druidProperties) throws SQLException {
        DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
        return druidProperties.dataSource(dataSource);
    }
}
